package com.ming.springboot.config;

import com.ming.springboot.vo.Some2Bean;
import com.ming.springboot.vo.SomeBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Scope;

/**
 * Created by mqsi on 2022/5/9 15:33
 */

@Configuration
public class AppConfig {


	@Bean
//	@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) // 多例
	@Scope(scopeName = ConfigurableBeanFactory.SCOPE_SINGLETON) // 单例
	@Lazy(value = false)
	@DependsOn(value = "some2Bean")
	public SomeBean someBean(){
		System.out.println("SomeBean 即将被初始化！");
		SomeBean someBean = new SomeBean();
		someBean.setName("SomeBean");
		return someBean;
	}

	@Bean
	public Some2Bean some2Bean(){
		System.out.println("Some2Bean 即将被初始化！");
		Some2Bean some2Bean = new Some2Bean();
		some2Bean.setName("Some2Bean");
		return some2Bean;
	}
}
